using System;
using UnityEngine;
using Unity.VisualScripting;
using ResourceUpdateSuccessEventArgs = UnityGameFramework.Runtime.ResourceUpdateSuccessEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Resource Update")]
    [UnitSurtitle("Success")]
    public sealed class ResourceUpdateSuccess : FrameworkEventUnit<ResourceUpdateSuccessEventArgs>
    {
        protected override int EventId => ResourceUpdateSuccessEventArgs.EventId;
        protected override string HookName => UGFHookNames.ResourceUpdateSuccess;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Name
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadPath
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadUri
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Length
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CompressedLength
        {
            get;
            private set;
        }

        protected override void Definition()
        {
            base.Definition();
            Name = ValueOutput<string>(nameof(Name));
            DownloadPath = ValueOutput<string>(nameof(DownloadPath));
            DownloadUri = ValueOutput<string>(nameof(DownloadUri));
            Length = ValueOutput<int>(nameof(Length));
            CompressedLength = ValueOutput<int>(nameof(CompressedLength));
        }

        protected override void AssignArguments(Flow flow, ResourceUpdateSuccessEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(Name, args.Name);
            flow.SetValue(DownloadPath, args.DownloadPath);
            flow.SetValue(DownloadUri, args.DownloadUri);
            flow.SetValue(Length, args.Length);
            flow.SetValue(CompressedLength, args.CompressedLength);
        }
    }
}